package com.yanqu.road.server.pb;

import com.yanqu.road.entity.activity.drawPictures.*;
import com.yanqu.road.pb.drawPicturesActivity.DrawPicturesProto;
import com.yanqu.road.server.manger.ServerLanguageMgr;

import java.util.Map;

public class DrawPicturesActivityPb {

    public static DrawPicturesProto.DrawPicturesUserActivityDataTemp.Builder parseUserDataTemp(UserDrawPicturesActivityData userActivityData, Map<Integer, UserPictures> picturesMap, Map<Integer, UserPicturesComb> combMap) {
        DrawPicturesProto.DrawPicturesUserActivityDataTemp.Builder temp = DrawPicturesProto.DrawPicturesUserActivityDataTemp.newBuilder();
        temp.setActivityid(userActivityData.getActivityId());
        temp.setCurrentPicturesId(userActivityData.getCurrentPicturesId());
        temp.setIntegral(userActivityData.getIntegral());
        if (picturesMap != null) {
            for (UserPictures userPictures : picturesMap.values()) {
                DrawPicturesProto.DrawPicturesUserPicDataTemp.Builder picTemp = DrawPicturesProto.DrawPicturesUserPicDataTemp.newBuilder();
                picTemp.setPicturesId(userPictures.getPicturesId());
                picTemp.setNum(userPictures.getNum());
                temp.addUserPicData(picTemp);
            }
        }
        if (combMap != null) {
            for (UserPicturesComb comb : combMap.values()) {
                DrawPicturesProto.DrawPictruresCombPrayTimesTemp.Builder combTemp = DrawPicturesProto.DrawPictruresCombPrayTimesTemp.newBuilder();
                combTemp.setCombId(comb.getCombId());
                combTemp.setTimes(comb.getTimes());
                temp.addUserCombPrayData(combTemp);
            }
        }
        return temp;
    }

    public static DrawPicturesProto.DrawPicturesConfigTemp.Builder parseConfigTemp(int activityId, Map<Integer, PicturesWeight> picConfigMap, Map<Integer, PicturesComb> combConfigMap, String language) {
        DrawPicturesProto.DrawPicturesConfigTemp.Builder temp = DrawPicturesProto.DrawPicturesConfigTemp.newBuilder();
        temp.setActivtyId(activityId);
        if (picConfigMap != null) {
            for (PicturesWeight picConfig : picConfigMap.values()) {
                DrawPicturesProto.DrawPicturesPicConifgTemp.Builder picTemp = DrawPicturesProto.DrawPicturesPicConifgTemp.newBuilder();
                picTemp.setId(picConfig.getId());
                picTemp.setName(ServerLanguageMgr.getContent(picConfig.getName(), language));
                picTemp.setOriginDesc(ServerLanguageMgr.getContent(picConfig.getOriginDesc(), language));
                picTemp.setDesc(ServerLanguageMgr.getContent(picConfig.getDesc(), language));
                picTemp.setQuality(picConfig.getQuality());
                picTemp.setWeight(picConfig.getWeight());
                picTemp.setIntegral(picConfig.getIntegral());
                picTemp.setSort(picConfig.getSort());
                picTemp.setOriginPoem(ServerLanguageMgr.getContent(picConfig.getOriginPoem(), language));
                temp.addPicConfig(picTemp);
            }
        }
        if (combConfigMap != null) {
            for (PicturesComb comb : combConfigMap.values()) {
                DrawPicturesProto.DrawPictureCombConfigTemp.Builder combTemp = DrawPicturesProto.DrawPictureCombConfigTemp.newBuilder();
                combTemp.setCombId(comb.getCombId());
                combTemp.setName(ServerLanguageMgr.getContent(comb.getName(), language));
                combTemp.setElement(comb.getElement());
                combTemp.setIntegral(comb.getIntegral());
                combTemp.setSort(comb.getSort());
                combTemp.setRewards(comb.getRewards());
                combTemp.setQuality(comb.getQuality());
                combTemp.setLimit(comb.getLimit());
                temp.addCombConfig(combTemp);
            }
        }
        return temp;
    }


}
